######################################################## COVID19 PEACE ################################################ 

install.packages("ggplot2")
library(ggplot2)


#####################################################################################################################


iraq <-read.csv("~/Dropbox/LockingDownViolence/Graphs/iraq.csv", header=TRUE, sep=",")

ggplot(data = iraq, aes(x =week)) +
  geom_bar(aes(y = isisandlikely_wk, fill = pcode),stat="identity")+
  scale_fill_manual(values=c("lightsteelblue2", "steelblue3",
                             "royalblue4", "black")) +
  geom_line(aes(y=vsisis_wklag, colour="anti-ISIS violence (lag)"), size=1) +
  geom_vline(xintercept = 62, color="grey28", size=.5, alpha=0.4 )+
  annotate("text", x = 62, y = 36, label = "COVID-19 First Death",
           vjust = -0.5, angle = 90, size=3)+
  geom_vline(xintercept = 63, color="grey28",linetype='dotted', size=.25, alpha=0.4 )+
  annotate("text", x = 63, y = 25, label = "COVID-19 curfews and internal travel bans imposed",
           vjust = 1.5, angle = 90, color="grey28", size=2)+
  geom_hline(yintercept=0, linetype='dotted', col = 'grey')+
  annotate("text", x = 21, y=0, label = "Ramadan 2019", vjust =
             1.5, size=2, fontface =2) +
  annotate("text", x = 71, y=0, label = "Ramadan 2020", vjust =
             1.5, size=2, fontface =2) +
  theme_bw() +
  theme(axis.text.x = element_text(angle=85, hjust = 1.0)) +
  theme(legend.position=c(.15,.90),
        legend.title=element_blank(),
        legend.key=element_blank(),
        plot.background=element_blank(),
        panel.grid.major=element_blank(),
        panel.grid.minor=element_blank(),
        legend.margin=margin(-5,-10,-10,0))+ 
  ylab("violent events (number)") +
  scale_y_continuous(, limits = c(0,40), breaks=seq(0, 50, by=5))+
  scale_x_continuous(, breaks=seq(0,78, by=2))+
  xlab("week") +
  theme(text=element_text(family="serif")) +
  ggtitle("Iraq")

egypt <-read.csv("~/Dropbox/LockingDownViolence/Graphs/egypt.csv", header=TRUE, sep=",")


ggplot(data = egypt, aes(x =week)) +
  geom_bar(aes(y = isisandlikely_wk, fill = pcode),stat="identity")+
  scale_fill_manual(values=c("lightsteelblue2", "steelblue3",
                             "royalblue4", "black")) +
  geom_line(aes(y=vsisis_wklag, colour="anti-ISIS violence (lag)"), size=1) +
  geom_vline(xintercept = 62, color="grey28", size=.5, alpha=0.4 )+
  annotate("text", x = 62, y = 36, label = "COVID-19 First Death",
           vjust = -0.5, angle = 90, size=3)+ 
  geom_vline(xintercept = 65, color="grey28",linetype='dotted', size=.25, alpha=0.4 )+
  annotate("text", x = 65, y = 25, label = "COVID-19 curfews and internal travel bans imposed",
           vjust = 1.5, angle = 90, color="grey28", size=2)+        
  geom_hline(yintercept=0, linetype='dotted', col = 'grey')+
  annotate("text", x = 21, y=0, label = "Ramadan 2019", vjust =
             1.5, size=2, fontface =2) +
  annotate("text", x = 71, y=0, label = "Ramadan 2020", vjust =
             1.5, size=2, fontface =2) +
  theme_bw() +
  theme(axis.text.x = element_text(angle=85, hjust = 1.0)) +
  theme(legend.position=c(.15,.90),
        legend.title=element_blank(),
        legend.key=element_blank(),
        plot.background=element_blank(),
        panel.grid.major=element_blank(),
        panel.grid.minor=element_blank(),
        legend.margin=margin(-5,-10,-10,0))+ 
  ylab("violent events (number)") +
  scale_y_continuous(, limits = c(0,40), breaks=seq(0, 50, by=5))+
  scale_x_continuous(, breaks=seq(0,78, by=2))+
  xlab("week") +
  theme(text=element_text(family="serif")) +
  ggtitle("Egypt")


syria <-read.csv("~/Dropbox/LockingDownViolence/Graphs/syria.csv", header=TRUE, sep=",")

ggplot(data = syria, aes(x =week)) +
  geom_bar(aes(y = isisandlikely_wk, fill = pcode),stat="identity")+
  scale_fill_manual(values=c("lightsteelblue2", "steelblue3",
                             "royalblue4", "black")) +
  geom_line(aes(y=vsisis_wklag, colour="anti-ISIS violence (lag)"), size=1) +
  geom_vline(xintercept = 65, color="grey28", size=.5, alpha=0.4 )+
  annotate("text", x = 65, y = 36, label = "COVID-19 First Death",
           vjust = -0.25, angle = 90, size=3)+
  geom_vline(xintercept = 64, color="grey28",linetype='dotted', size=.25, alpha=0.4 )+
  annotate("text", x = 64, y = 25, label = "COVID-19 curfews and internal travel bans imposed",
           vjust = -0.25, angle = 90, color="grey28", size=2)+
  geom_hline(yintercept=0, linetype='dotted', col = 'grey')+
  annotate("text", x = 21, y=0, label = "Ramadan 2019", vjust =
             1.5, size=2, fontface =2) +
  annotate("text", x = 71, y=0, label = "Ramadan 2020", vjust =
             1.5, size=2, fontface =2) +
  theme_bw() +
  theme(axis.text.x = element_text(angle=85, hjust = 1.0)) +
  theme(legend.position=c(.15,.90),
        legend.title=element_blank(),
        legend.key=element_blank(),
        plot.background=element_blank(),
        panel.grid.major=element_blank(),
        panel.grid.minor=element_blank(),
        legend.margin=margin(-5,-10,-10,0))+ 
  ylab("violent events (number)") +
  scale_y_continuous(, limits = c(0,40), breaks=seq(0, 50, by=5))+
  scale_x_continuous(, breaks=seq(0,78, by=2))+
  xlab("week") +
  theme(text=element_text(family="serif")) +
  ggtitle("Syria")

#Supplementary Graphs##

allstates <-read.csv("~/Dropbox/LockingDownViolence/Graphs/allstates.csv", header=TRUE, sep=",")

ggplot(data = allstates, aes(x =week)) +
  geom_bar(aes(y = sum_isisandlikely_wk, fill = sum_pcode),stat="identity")+
  scale_fill_manual(values=c("lightsteelblue2", "steelblue3",
                             "royalblue4", "black")) +
  geom_line(aes(y=sum_vsisis_wklag_wk, colour="anti-ISIS violence (lag)"), size=1) +
  geom_vline(xintercept = 62, color="grey28", size=.5, alpha=0.4 )+
  annotate("text", x = 62, y = 32, label = "COVID-19 First Death, Egypt and Iraq",
           vjust = -0.5, angle = 90, size=3)+
  geom_vline(xintercept = 65, color="grey28", size=.5, alpha=0.4 )+
  annotate("text", x = 65, y = 32, label = "COVID-19 First Death, Syria",
           vjust = -0.5, angle = 90, size=3)+         
  #geom_vline(xintercept = 63, color="grey28",linetype='dotted', size=.25, alpha=0.4 )+
  #annotate("text", x = 63, y = 25, label = "COVID-19 curfews and internal travel bans imposed",
           #vjust = 1.5, angle = 90, color="grey28", size=2)+
  geom_hline(yintercept=0, linetype='dotted', col = 'grey')+
  annotate("text", x = 21, y=0, label = "Ramadan 2019", vjust =
             1.5, size=2, fontface =2) +
  annotate("text", x = 71, y=0, label = "Ramadan 2020", vjust =
             1.5, size=2, fontface =2) +
  theme_bw() +
  theme(axis.text.x = element_text(angle=85, hjust = 1.0)) +
  theme(legend.position=c(.12,.91),
        legend.title=element_blank(),
        legend.key=element_blank(),
        plot.background=element_blank(),
        panel.grid.major=element_blank(),
        panel.grid.minor=element_blank(),
        legend.margin=margin(-5,-10,-10,0))+ 
  ylab("violent events (number)") +
  scale_y_continuous(, limits = c(0,40), breaks=seq(0, 50, by=5))+
  scale_x_continuous(, breaks=seq(0,78, by=2))+
  xlab("week") +
  theme(text=element_text(family="serif")) +
  ggtitle("All States (Egypt, Iraq and Syria)")

